﻿<UserControl x:Class="FlowgraphViewer.Views.FlowNodeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="400"
             
             >

    <UserControl.Resources>
        <DataTemplate x:Key="NodeInputDataTemplate">
            <Grid Background="Yellow"  ToolTipService.ToolTip="{Binding Description}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="12"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Path Height="12" Stretch="Fill" Stroke="#505050" StrokeThickness="1" Data="M308.5625,416.25L297.2495,416.25L297.2495,407.312L308.5625,407.312L308.5625,402.625L317.0625,412.562L308.5625,420.875L308.5625,416.25z" >
                    <Path.Fill>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#FF009500"/>
                            <GradientStop Color="#FF00D700" Offset="1"/>
                        </LinearGradientBrush>
                    </Path.Fill>
                </Path>
                <TextBlock FontSize="10" Height="12" Grid.Column="1" Text="{Binding Name}" TextWrapping="Wrap" Margin="5,0,0,0" VerticalAlignment="Center"/>

            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="NodeOutputDataTemplate">
            <Grid Background="Pink"  ToolTipService.ToolTip="{Binding Description}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="12"/>
                </Grid.ColumnDefinitions>
                <Path Grid.Column="1" Height="12" Stretch="Fill" Stroke="#505050" StrokeThickness="1" Data="M308.5625,416.25L297.2495,416.25L297.2495,407.312L308.5625,407.312L308.5625,402.625L317.0625,412.562L308.5625,420.875L308.5625,416.25z" >
                    <Path.Fill>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#FF009500"/>
                            <GradientStop Color="#FF00D700" Offset="1"/>
                        </LinearGradientBrush>
                    </Path.Fill>
                </Path>
                <TextBlock HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="0" Text="{Binding Name}" TextWrapping="Wrap" Margin="5,0,0,0" VerticalAlignment="Center"/>

            </Grid>
        </DataTemplate>
        <Style TargetType="ListBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <StackPanel>
                            <ItemsPresenter />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>
    <!--<Border x:Name="border" BorderThickness="1" BorderBrush="White">
        <Grid Background="#d2d2d2" x:Name="LayoutRoot">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Rectangle Grid.ColumnSpan="2">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFCDDBCD" Offset="0"/>
                        <GradientStop Color="#FF1CC91C" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <ListBox x:Name="lstInputs" ItemTemplate="{StaticResource NodeInputDataTemplate}" BorderBrush="Transparent" Grid.Row="1" Grid.Column="0"  ItemsSource="{Binding Path=Node.FlowNode.Inputs}" >
            </ListBox>
            <ListBox x:Name="lstOutputs" Background="Yellow" BorderBrush="Transparent" Grid.Row="1" Grid.Column="1" ItemTemplate="{StaticResource NodeOutputDataTemplate}" ItemsSource="{Binding Path=Node.FlowNode.Outputs}"/>
            <TextBlock x:Name="txtName" Text="{Binding Node.FlowNode.Name}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5" Grid.ColumnSpan="2"/>
        </Grid>
    </Border>-->
    <Border Background="White" CornerRadius="5" BorderThickness="1" BorderBrush="#FF2F497C">
        <Border.Effect>
            <DropShadowEffect Opacity="0.25" ShadowDepth="3"/>
        </Border.Effect>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Background="#FF2F497C" CornerRadius="5,5,0,0" Margin="0,-1,0,0">
                <TextBlock Text="{Binding Node.FlowNode.Name}" Foreground="White" FontFamily="Verdana" VerticalAlignment="Center" Margin="5" />
            </Border>
            <Grid Grid.Row="1" Margin="0,0,0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <ItemsControl ItemsSource="{Binding Node.FlowNode.Inputs}">
                    <ItemsPanelTemplate>
                        <StackPanel HorizontalAlignment="Left" />
                    </ItemsPanelTemplate>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" Foreground="#FF2F497C" Margin="5,0" HorizontalAlignment="Left"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>


                <ItemsControl Grid.Column="1" ItemsSource="{Binding Node.FlowNode.Outputs}">
                    <ItemsPanelTemplate>
                        <StackPanel HorizontalAlignment="Right" />
                    </ItemsPanelTemplate>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" Foreground="#FF2F497C" Margin="5,0" HorizontalAlignment="Right"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

            </Grid>


        </Grid>
    </Border>

</UserControl>
